
package firewatig

class Firefox {
	
	JSSH jssh;
	
	Firefox(){
		 jssh = new JSSH();
	 }

	/**
	 *   goto(url)

Navigate to the specified URL.

 * url - string - the URL to navigate to

	 */
	 def go = { url ->
	 	jssh.say("loadURI('$url')");
	 	jssh.bwait()
	 }
	 
	 /**

This is the main method for accessing a text field. Usually an <input type = text> HTML tag. or a text area - a <textarea> tag

 *  how   - symbol - how we access the field, :index, :id, :name etc
 *  what  - string, integer or regular expression - what we are looking for,

Valid values for ‘how’ are listed in the Watir Wiki - wiki.openqa.org/display/WTR/Methods+supported+by+Element

returns a TextField object

Typical Usage

   ie.text_field(:id,   'user_name')                 # access the text field with an ID of user_name
   ie.text_field(:name, 'address')                   # access the text field with a name of address
   ie.text_field(:index, 2)                          # access the second text field on the page (1 based, so the first field is accessed with :index,1)
   ie.text_field(:xpath, "//textarea[@id='user_name']/")    # access the text field with an ID of user_name

	  */
	 def textField = { how, what ->
	 	return new Element(jssh, "input", how, what)
	 }

/**
button(how, what=nil)

This is the main method for accessing a button. Often declared as an <input type = submit> tag.

 *  how   - symbol - how we access the button, :index, :id, :name etc
 *  what  - string, integer or regular expression - what we are looking for,

Valid values for ‘how’ are listed in the Watir Wiki - wiki.openqa.org/display/WTR/Methods+supported+by+Element

Returns a Button object.

Typical usage

   ie.button(:id,    'b_1')                             # access the button with an ID of b_1
   ie.button(:name,  'verify_data')                     # access the button with a name of verify_data
   ie.button(:value, 'Login')                           # access the button with a value (the text displayed on the button) of Login
   ie.button(:caption, 'Login')                         # same as above
   ie.button(:value, /Log/)                             # access the button that has text matching /Log/
   ie.button(:index, 2)                                 # access the second button on the page (1 based, so the first button is accessed with :index,1)
   ie.button(:class, 'my_custom_button_class')          # access the button with a class of my_custom_button_class
   ie.button(:xpath, "//input[@value='Click Me']/")     # access the button with a value of Click Me

Accessing a Button nested within another element

   ie.div(:class, 'xyz').button(:index, 2)              # access a div of class xyz, and the 2nd button within that div

If only a single parameter is supplied, then :value is used

   ie.button('Click Me')                                # access the button with a value of Click Me

*/
	 def button = { how, what ->	 	
	 	return new Element(jssh, "input", how, what)
	 }
	  
/**
 *   text()

The text of the current page

 */
	 def text = { 
		jssh.log = false
		try {
			return jssh.say("doc().body.innerHTML");
		} finally {
			jssh.log = true
		}
	 }
	
/**
		  link(how, what=nil)

		  This is the main method for accessing a link.

		   *  how   - symbol - how we access the link, :index, :id, :name, :title, :text, :url
		   *  what  - string, integer or regular expression - what we are looking for,

		  Valid values for ‘how’ are listed in the Watir Wiki - wiki.openqa.org/display/WTR/Methods+supported+by+Element

		  returns a Link object

		  Typical Usage

		    ie.link(:url, /login/)              # access the first link whose url matches login. We can use a string in place of the regular expression
		                                        # but the complete path must be used, ie.link(:url, 'http://myserver.com/my_path/login.asp')
		    ie.link(:index,2)                   # access the second link on the page
		    ie.link(:title, "Picture")         # access a link using the tool tip
		    ie.link(:text, 'Click Me')          # access the link that has Click Me as its text
		    ie.link(:xpath, "//a[contains(.,'Click Me')]/")      # access the link with Click Me as its text

*/
	def link = { how, what ->	
		return new Element(jssh, "a", how, what)
    }
}